<?xml version="1.0" encoding="UTF-8" ?>
<testsuites errors="<%= module.errors %>"
            failures="<%= module.failures %>"
            tests="<%= module.tests %>">

  <testsuite name="<%= className %>" id="<%= suiteKey %>"
    errors="<%= module.errors %>" failures="<%= module.failures %>" hostname="" package="<%= module.group || moduleName %>" skipped="<%= (Array.isArray(module.skippedAtRuntime)) ? module.skippedAtRuntime.length : 0 %>"
    tests="<%= module.tests %>" time="<%= module.time %>" timestamp="<%= module.timestamp %>">
  <% for (var item in module.completed) {
    var testcase = module.completed[item];
    var assertions = testcase.assertions %>
    <testcase name="<%= item %>" classname="<%= className %>" time="<%= testcase.time %>" assertions="<%= assertions.length %>"><%
      for (var i = 0; i < assertions.length; i++) { %><% if (assertions[i].failure) { %>  <failure message="<%= assertions[i].message %>"><%= assertions[i].stackTrace %></failure><% } %>
<% if (assertions[i].screenshots && assertions[i].screenshots.length > 0) { %><system-out><% for (var j = 0; j < assertions[i].screenshots.length; j++) { %>[[ATTACHMENT|<%= assertions[i].screenshots[j] %>]]<% } %></system-out><% } %>
    <% }
    if (assertions.length === 0 && testcase.failed) { %>
      <failure message="<%= testcase.message %>"><%= testcase.stackTrace %></failure><% }
    if (testcase.errors > 0 && testcase.stackTrace) { %>
    <error <% if (testcase.lastError && testcase.lastError.message) { %>message="<%= testcase.lastError.message %>" <% } %>type="error"><![CDATA[
    <%= testcase.stackTrace %>
    ]]></error>
    <% } %>
    </testcase>
  <% } %>

  <% if (systemerr != '') { %>
    <system-err>
      <%= systemerr %>
    </system-err>
  <% } %>

    <% if (module.lastError && Object.keys(module.completed).length === 0) { %>
    <error message="<%= module.lastError.message %>"><![CDATA[
      <%= module.lastError.stack %>
      ]]></error>  <% } %>

  <% if (module.skippedAtRuntime && (module.skippedAtRuntime.length > 0)) { %>
    <% for (var j = 0; j < module.skippedAtRuntime.length; j++) { %>
    <testcase
      name="<%= module.skippedAtRuntime[j] %>" classname="<%= className %>">
      <skipped />
    </testcase>
    <% } %>
  <% } %>
  </testsuite>
</testsuites>
